package autoTest.database;

import java.util.HashSet;
import java.util.Set;

import autoTest.command.Params;
import autoTest.utils.TextUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class DataElement {
	private String taskId;
	private String result;
	private String deviceSet;
	
	public DataElement() {
		taskId = new String("");
		JSONObject jo = new JSONObject();
		JSONArray ja = new JSONArray();
		jo.put(Params.RESULT_ARRAY, ja);
		result = jo.toString();
		deviceSet = new String("");
	}
	
	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}
	
	public String getTaskId() {
		return this.taskId;
	}
	
	public void setResult(String result) {
		this.result = result;
	}
	
	public String getResultStr() {
		return this.result;
	}
	
	public JSONObject getResultObject() {
		return JSONObject.fromObject(result);
	}
	
	public void setDeviceSet(String deviceSet) {
		this.deviceSet = deviceSet;
	}
	
	public String getDeviceSet() {
		return this.deviceSet;
	}
	
	public static Set<String> deviceIDStr2DeviceSet(String deviceIDStr) {
		Set<String> retSet = new HashSet<String>();
		String[] deviceIDArr = deviceIDStr.split(",");
		for (String deviceID : deviceIDArr) {
			if (!TextUtils.isEmpty(deviceID)) {
				retSet.add(deviceID);
			}
		}
		return retSet;
	}
}
